package vcp.client.reports;

import java.io.Serializable;

import vcp.entity.Worker;
import vcp.enums.ReportType;

public class WorkerRecordsReport extends ReportAbstract
{

	/**
	 * 
	 */
	private static final long serialVersionUID = 8710021987379444773L;

	public WorkerRecordsReport ()
	{
		super(ReportType.WORKER_RECORDS);
	}

	// ****************************************************************************************************************************
	// Public methods
	// ****************************************************************************************************************************
	public void add ( Worker worker )
	{
		WorkerRecordsRow workerRecordsRow = new WorkerRecordsRow();
		workerRecordsRow.setWorkerName(worker.getUserFirstName() + " " + worker.getUserLastName());
		workerRecordsRow.seteMail(worker.getUserEmail());
		workerRecordsRow.setJobType(worker.getJobType().toString());
		workerRecordsRow.setDepartment(worker.getDepartment().toString());
		workerRecordsRow.setSiteName(worker.getSites().size() > 1
																	? "---"
																	: worker.getSites().get(0).getSiteName());

		this.reportDataRow.add(workerRecordsRow);
	}

	// ****************************************************************************************************************************
	// ReportAbstract methods
	// ****************************************************************************************************************************
	@Override
	public String[] getHeaders ()
	{
		return new String[]
			{ "Name"
					, "eMail"
					, "JobType"
					, "Department"
					, "Site" };
	}

	// ****************************************************************************************************************************
	// Private class
	// ****************************************************************************************************************************

	/**
	 * 
	 * @author VCP team
	 *         <p>
	 *         worker row wrapper class
	 */

	private class WorkerRecordsRow implements Serializable, IWrapperConverter
	{

		/**
		 * 
		 */
		private static final long serialVersionUID = - 8783399642490359948L;

		// ****************************************************************************************************************************
		// Setter-Getter methods
		// ****************************************************************************************************************************
		private String siteName;

		/**
		 * getter
		 * 
		 * @return worker site name
		 */
		public String getSiteName ()
		{
			return this.siteName;
		}

		/**
		 * set worker site
		 * 
		 * @param siteName
		 */
		public void setSiteName ( String siteName )
		{
			this.siteName = siteName;
		}

		private String department;

		/**
		 * 
		 * @return worker department
		 */
		public String getDepartment ()
		{
			return this.department;
		}

		/**
		 * set worker department
		 * 
		 * @param department
		 */
		public void setDepartment ( String department )
		{
			this.department = department;
		}

		private String jobType;

		/**
		 * 
		 * @return worker jop type
		 */
		public String getJobType ()
		{
			return this.jobType;
		}

		/**
		 * set worker job type
		 * 
		 * @param jobType
		 */
		public void setJobType ( String jobType )
		{
			this.jobType = jobType;
		}

		private String eMail;

		/**
		 * 
		 * @return worker email
		 */
		public String geteMail ()
		{
			return this.eMail;
		}

		/**
		 * set worker email
		 * 
		 * @param eMail
		 */
		public void seteMail ( String eMail )
		{
			this.eMail = eMail;
		}

		private String workerName;

		/**
		 * 
		 * @return worker first & last name
		 */
		public String getWorkerName ()
		{
			return this.workerName;
		}

		/**
		 * set worker first & last name
		 * 
		 * @param workerName
		 */
		public void setWorkerName ( String workerName )
		{
			this.workerName = workerName;
		}

		// ****************************************************************************************************************************
		// IWrapperConverter class
		// ****************************************************************************************************************************
		@Override
		public Object[] toObjectArray ()
		{
			return new Object[]
				{ this.getWorkerName()
						, this.geteMail()
						, this.getJobType()
						, this.getDepartment()
						, this.getSiteName() };
		}
	}
}
